//
//  DeviceConfig.swift
//  iOSProjectExtensionSwift
//
//  Created by Apple on 2020/1/11.
//  Copyright © 2020 lidianchao. All rights reserved.
//

import Foundation
import UIKit
//设备相关
let kAppWindow = UIApplication.shared.delegate?.window;
let DeviceWidth = UIScreen.main.bounds.size.width;
let DeviceHeight = UIScreen.main.bounds.size.height;
//判断是否是ipad
let isPad = (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad);
//判断iPhone4系列
let kiPhone4 =  (UIScreen.instancesRespond(to: #selector(getter: UIScreen.main.currentMode)) ? CGSize(width: 640, height: 960).equalTo((UIScreen.main.currentMode?.size)!) && !isPad : false);

//判断iPhone5系列
let kiPhone5 =  (UIScreen.instancesRespond(to: #selector(getter: UIScreen.main.currentMode)) ? CGSize(width: 640, height: 1136).equalTo((UIScreen.main.currentMode?.size)!) && !isPad : false);
//判断iPhone6系列
let kiPhone6 =  (UIScreen.instancesRespond(to: #selector(getter: UIScreen.main.currentMode)) ? CGSize(width: 750, height: 1334).equalTo((UIScreen.main.currentMode?.size)!) && !isPad : false);
//判断iphone6+系列
let kiPhone6Plus =  (UIScreen.instancesRespond(to: #selector(getter: UIScreen.main.currentMode)) ? CGSize(width: 1242, height: 2208).equalTo((UIScreen.main.currentMode?.size)!) && !isPad : false);

//iPhoneX系列

//判断是否是iphone x，最新判断方法

func kDevice_Is_iPhoneX () ->Bool {
    if #available(iOS 11, *) {
          guard let w = UIApplication.shared.delegate?.window, let unwrapedWindow = w else {
              return false
          }
          
          if unwrapedWindow.safeAreaInsets.left > 0 || unwrapedWindow.safeAreaInsets.bottom > 0 {
              print(unwrapedWindow.safeAreaInsets)
              return true
          }
    }
    return false
}
let Height_SafeAreaTabBa = CGFloat(kDevice_Is_iPhoneX() ? 34 : 0)
//状态栏
let Height_StatusBar =  CGFloat(kDevice_Is_iPhoneX () ? 44.0 : 20.0)
//导航栏高度
let Height_NavBar = CGFloat(Height_StatusBar+44)
//tabbar高度,iPhoneX包含底部安全高度
let Height_TabBar = CGFloat((kDevice_Is_iPhoneX () ? 83.0 : 49.0))

